#include<iostream>
#include<string>
#include<vector>
#include<deque>
#include<time.h>
#include<list>


using std::endl;
using std::cout;
using std::string;
using std::vector;
using std::deque;
using std::list;

class Person
{
public:
    Person(const char* name,float score=0)
        :_name(name)
         ,_score(score)
    {
        cout<<"构造函数"<<endl;
    }
    void setscore(float score)
    {
        _score=score;
    }
    void print()
    {
        cout<<"name: "<<_name<<" score "<<_score<<endl;
    }
private:
    string _name;
    float _score;
};
float sort(deque<int>& deq)
{
    cout<<endl;
    for(auto i=deq.begin();i!=deq.end();++i)
    {
        for(auto j=i;j>deq.begin();--j)
        {
            if(*j<*(j-1))
            {
                float temp=*(j-1);
                *(j-1)=*j;
                *j=temp;
            }
            else 
            {
                break;
            }
        }
    }
    for(auto& i:deq)
    {
        cout<<i<<" ";
    }

    deq.erase(deq.begin());
    deq.erase(deq.end()-1);

    float sum=0;
    for(auto& i:deq)
    {
        sum +=i;
    }
    return sum/8;
}
int main(void)
{
    srand(time(NULL));
    vector<Person> vec={{"he"},{"wu"},{"tu"},{"qr"},{"yu"}};
    for(auto&i:vec)
    {
        deque<int> deq;
        for(int j=0;j<10;j++)
        {
            deq.push_back(rand()%10);
            cout<<deq.back()<<" ";
        }
        i.setscore(sort(deq));
        cout<<endl;
        i.print();
    cout<<endl<<endl<<endl;
    }
}
    
